<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<c:choose>
	<c:when test="${customers != nul}">
		<p>All customers list</p>
		<table class="table table-hover">
			<thead>
				<tr>
					<th>Klient</th>
					<!-- 
					<th>Pesel</th>
					<th>E-mail</th>
					 -->
					<th>Adres zamieszkania</th>
					<th>Adres korespondencyjny</th>
					<th>Kategoria</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach var="customer" items="${customers}">
					<tr>
						<td>
							<c:out value="${customer.firstName}"/> <c:out value="${customer.lastName}"/>
						</td>
						<!-- 
						<td>
							<c:out value="${customer.pesel}" />
						</td>
						<td>
							<c:out value="${customer.email}" />
						</td>
						 -->
						<td>
							<c:out value="${customer.liveAddress.city}" />,
							ul. <c:out value="${customer.liveAddress.street}" />
							<c:out value="${customer.liveAddress.buildingNumber}" />
							<c:if test="${customer.liveAddress.flatNumber != null}">
								/ <c:out value="${customer.liveAddress.flatNumber}" />
							</c:if>
						</td>
						<td>
							<c:out value="${customer.mailDropAddress.city}" />,
							ul. <c:out value="${customer.mailDropAddress.street}" />
							<c:out value="${customer.mailDropAddress.buildingNumber}" />
							<c:if test="${customer.mailDropAddress.flatNumber != null}">
								/ <c:out value="${customer.mailDropAddress.flatNumber}" />
							</c:if>
						</td>
						<td>
							<c:forEach var="rank" items="${customer.ranks}">
								<c:out value="${rank.groupName}" /> 
							</c:forEach>
						</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</c:when>
	<c:otherwise>
		<p>Sorry no data found ;(</p>
	</c:otherwise>
</c:choose>
